package com.yanchangapp.adapter;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.model.bean.MenuIcons;
import com.yanchangapp.ui.activity._n_manage.DailyPlanActivity;
import com.yanchangapp.ui.activity._n_manage.HistoryPlanActivity;
import com.yanchangapp.ui.activity._n_manage.LinkManActivity;
import com.yanchangapp.ui.activity._n_manage.LinkWorkItemActivity;
import com.yanchangapp.ui.activity._n_manage.WorkItemActivity;
import com.yanchangapp.ui.activity.mail.WebViewActivity;
import com.yanchangapp.ui.activity.purchase.POrderListActivity;
import com.yanchangapp.ui.activity.purchase.apply.GoodsApplyActivity;
import com.yanchangapp.ui.activity.purchase.approve.GoodsApproveActivity;
import com.yanchangapp.ui.activity.purchase.contract.ContractListActivity;
import com.yanchangapp.ui.activity.purchase.record.GoodsRecordActivity;
import com.yanchangapp.R;
import com.yanchangapp.commom.MenuIdentify;
import com.yanchangapp.model.bean.ComposeMenuIcons;
import com.yanchangapp.ui.activity.mail.MailHomeActivity;
import java.util.List;

public class WorkComposeAdapter extends BaseQuickAdapter<ComposeMenuIcons, BaseViewHolder> {
    private Activity mActivity;
    public WorkComposeAdapter(int layoutResId, @Nullable List<ComposeMenuIcons> data, Activity activity) {
        super(layoutResId, data);
        mActivity = activity;
    }

    @Override
    protected void convert(BaseViewHolder helper, ComposeMenuIcons item) {
        helper.setText(R.id.tvTitle,item.getTitle());
        RecyclerView recyclerView =  helper.getView(R.id.innerRecycle);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext,4,LinearLayoutManager.VERTICAL,false));
        HomeIconsAdapter homeIconsAdapter = new HomeIconsAdapter(R.layout.item_inner_icons,item.getList());
        // 点击事件....
        homeIconsAdapter.setOnItemClickListener((adapter, view, position) -> {
            MenuIcons menuIcons = item.getList().get(position);
            int id = menuIcons.getId();
            Log.e("菜单", "convert: "+id );
            if (id == MenuIdentify.MAIL_SECOND.id){
                MailHomeActivity.show(mActivity);
            } else if (id == MenuIdentify.PLAN_DAILY.id){
                // WebViewActivity.show(mActivity,menuIcons.getMobileAddress());
            }else if(id == MenuIdentify.ORDER_LIST.id){
                // 进行采购订单列表的跳转
                POrderListActivity.show(mActivity);
            }else if (id == MenuIdentify.CONTRACT.id){
                ContractListActivity.show(mActivity);
            }else if (id == MenuIdentify.P_APPLY.id){
                GoodsApplyActivity.show(mActivity);
            }else if (id == MenuIdentify.P_RECORD.id){
                GoodsRecordActivity.show(mActivity);
            }else if (id == MenuIdentify.P_APPROVE.id){
                GoodsApproveActivity.show(mActivity);
            }else if (id == MenuIdentify.N_WORK_ITEM.id){
                WorkItemActivity.show(mActivity);
            }else if (id == MenuIdentify.N_DAILY_PLAN.id){
                DailyPlanActivity.show(mActivity);
            }else if (id == MenuIdentify.N_HISTORY_PLAN.id){
                HistoryPlanActivity.show(mActivity);
            }else if (id == MenuIdentify.N_LINK_MAN.id){
                LinkManActivity.show(mActivity);
            }else if (id == MenuIdentify.N_LINK_WORK_ITEM.id){
                LinkWorkItemActivity.show(mActivity);
            }else {
                WebViewActivity.show(mActivity,menuIcons.getMobileAddress());
            }
        });
        recyclerView.setAdapter(homeIconsAdapter);
    }

}
